package com.googlecode.groovyworks.grails;

import org.codehaus.groovy.grails.compiler.support.GrailsResourceLoader;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

public class JUnitResourceLoaderFactoryBean implements FactoryBean,
		InitializingBean {
	private GrailsResourceLoader resourceLoader;

	public Object getObject() throws Exception {
		return this.resourceLoader;
	}

	public Class getObjectType() {
		return GrailsResourceLoader.class;
	}

	public boolean isSingleton() {
		return true;
	}

	public void afterPropertiesSet() throws Exception {
		ClassPathResource controllerResource = new ClassPathResource(
				"/WEB-INF/grails-app/controllers/RaceController.groovy");
		ClassPathResource domainResource = new ClassPathResource(
				"/WEB-INF/grails-app/domain/Race.groovy");

		resourceLoader = new GrailsResourceLoader(new Resource[] {
				controllerResource, domainResource });
	}

}
